home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / Bonus / Plasmatech / ptscp_eval.exe / %MAINDIR% / Interface / UPTShellControls.int < prev    next >
Encoding:
Text File  |  2001-08-31  |  36.1 KB  |  803 lines

  1. unit UPTShellControls; // Copyright ⌐ 1996-2001 Plasmatech Software Design. All rights reserved.
  2. {
  3.  Shell Control Pack
  4.  Version 1.6
  5.  
  6.  Components
  7.  ----------
  8.    TPTShellTree   - Explorer-like tree view of the namespace.
  9.    TPTShellList   - Explorer-like list view of folder contents.
  10.    TPTShellCombo  - Explorer-like combobox of the namespace.
  11.  
  12.  History
  13.  ===================================================================================================
  14.  V1.6   2Jul01 Added Delphi 6 support.
  15.                Fixed popup menu for root-nodes. If the root node is not the Desktop, then the right
  16.                  click popup menu is now correctly handled.
  17.                Fixed 'access denied' error displayed on certain Windows 2000 systems due to the
  18.                  "System Volume Information" folder.
  19.                Fixed background color of state image list in TPTShellTree - now matches
  20.                  TPTShellTree.
  21.  V1.5c 30Mar01 Fixed AV which sometimes occured in TPTShellTree on Windows 98 when folders were
  22.                  created and deleted.
  23.                Fixed TPTShListData so that new columns can be added.
  24.                Changed to central acquisition of shell's IMalloc interface.
  25.  V1.5b 12Dec00 Fixed potential memory leak under Windows 2000.
  26.                Fixed potential AV when performing multiple drag/drop operations with TPTShellTree.
  27.                Fixed problem with image list. Certain types of images would show with a black border
  28.                  on some Windows/IE/comctl combinations.
  29.                Fixed. Refreshes of TPTShellTree could cause the currently selected node to jump up
  30.                  one or two levels.
  31.  V1.5a 14May00 Added. Support for Windows 2000 - correct column information is now used for most
  32.                  non-filesystem folders.
  33.                Changed. Removed support for CF_TEXT format in drag/drop operations. This more
  34.                  closely matches Windows Explorer and prevents issues with some drop-target
  35.                  applications (such as Wordperfect).
  36.                Fixed. Improved handling of case where a background refresh occurs, while a popup
  37.                  menu or edit mode is active. Refreshes are deferred until the operation is
  38.                  complete.
  39.                Fixed. Published RightClickSelect property in TPTShellTree.
  40.  V1.5   3Mar00 Added C++Builder 5 support.
  41.                Improved performance of TPTShellCombo control by using new OnGetItemData method
  42.                  of TPTImageCombo class.
  43.                Fixed. Reversed the sort direction icon, now up=ascending, down=descending.
  44.                Fixed. Published OnInfoTip event in TPTShellList.
  45.                Fixed. TPTShellList.OnItemContextMenu and TPTShellTree.OnNodeContextMenu are now
  46.                  invoked correctly.
  47.                Fixed. TPTShellList Drag/drop now behaves more like Windows Explorer. Dropping on an
  48.                  item that does not accept dropped files now 'drops-through' to the owning folder.
  49.                  The effect is like you had dropped in empty white-space.
  50.                Fixed. The update in v1.4a to better handle removable and dynamically mounted drives
  51.                  can cause excessive floppy drive access on some systems. It seems to happen only
  52.                  on IE5 systems, but only rarely. On those systems on which it does happen, it is
  53.                  reproducible. With this fix, those systems will only access the floppy drive after
  54.                  a removable disk is changed, or a drive is mounted/unmounted.
  55.  V1.4a 15Dec99 Fixed update and refresh of drive volume labels, dynamically mounted drives etc.
  56.                Fixed problem where each new CDROM mounted would give a new tree node, without
  57.                  deleting the previous node for that drive.
  58.                Fixed case where folder column widths were sometimes not remembered between folders.
  59.                Fixed problem when showing non-folders in the TPTShellTree controls by using the
  60.                  ptstoIncludeNonFiles option. File list changes were not automatically detected,
  61.                  even when the ptstoDynamicRefresh option was set. Manually refreshing the tree
  62.                  with F5 or by calling RefreshNodes also failed to reflect changes.
  63.                Fixed OnContextPopup event in Delphi 5, now correctly published.
  64.                Fixed OnInsertItem event now called for root node in TPTShellTree control.
  65.                Added SFGAO_VALIDATE to some GetAttributes calls. Should help removeable disk
  66.                  changes be handled better. Definately makes ZIP disks work better.
  67.  V1.4  14Sep99 Improved support for custom sorting using OnCompare and SortColumn:=0.
  68.                Fixed OnCustomDraw, and OnCustomDrawItem. They are now published.
  69.                Fixed editing of non-filesystem, renamable items like My Computer. It now works.
  70.                Fixed OnGetImageIndex event of TPTShellList, it is now called correctly.
  71.                Fixed problem where if a mapped network drive's server was shutdown, CPU utilization
  72.                  would go to 100%.
  73.                Fixed drag-drop error case where dropping from some data sources which don't support
  74.                  CF_IDLIST format would cause an access violation.
  75.  V1.3h 29Mar99 Added support for Rename menu item in filesystem context menus.
  76.                Changed PTShCreateNewFolder to support drives without long-filename capability.
  77.                Improved robustness of TPTShellLocator ReadData and WriteData methods.
  78.                Improved performance of some loops in TPTCustomShellList, now using GetNextItem
  79.                  instead of iterating through the whole list.
  80.                Fixed key handling of Shift/Delete. This key combo now deletes files immediately
  81.                  bypassing the Recycle Bin in the same way as Windows Explorer.
  82.                Fixed problem where mouse wheel was unresponsive for TPTShellList controls in
  83.                  vsList mode.
  84.                Fixed OnDblClickOpen event in TPTShellList control. It was not being called when
  85.                  multiple items were opened simultaneously with a double click or Enter key.
  86.  V1.3g  1Dec98 Added TPTCustomShellList.DoCommandForItem method.
  87.                Added mouse wheel support to TPTShellTree and TPTShellList (Delphi 4 only).
  88.                Added OnSelectItem event to TPTShellList (Delphi 4 only).
  89.                Added support for more types of Explorer extensions (such as PicaView). Shell menu
  90.                  handling now mimics better the behaviour of modern variants of Windows Explorer.
  91.                Added OnFillStart event to TPTShellTree and TPTShellList.
  92.                Changed OnFillComplete is now called at then end of Refresh methods as well as at
  93.                  the end of FillItems methods.
  94.                Changed TPTCustomShellTree.ShellSelCount. Now very much faster for large lists.
  95.                Fixed bug in TPTCustomShellList.SetFileFilter method.
  96.                Fixed problem where multiple filters would cause an empty floppy drive to timeout
  97.                  for each filter. Now stops after the first timeout.
  98.  V1.3f 12Jul98 TPTCustomShellTree.SortNode moved from private to public section.
  99.                Changed some parameter types to better support C++Builder 3.
  100.                Changed some expressions and types to better support Delphi 4.
  101.  V1.3e 22Apr98 Fixed problem with TPTCustomShellList.RefreshItems not working correctly under Windows NT. Also
  102.                  improved refresh algorithm making it another 2-3x faster.
  103.  V1.3d 18Apr98 Added OnCompare event to TPTShellList. If SortColumn is 0, then the OnCompare event is
  104.                  called allowing definition of custom sort orders.
  105.                Added OnFolderChanged event to TPTShellList. This event is fired after the Folder property changes.
  106.                Added OnInsertItem event to TPTShellTree. This event is called after a node has been
  107.                  added to the tree.
  108.                Changed algorithm used in TPTShellList.RefreshItems. It is now at least 100x faster on large folders.
  109.                Fixed Delphi drag support in TPTShellTree. If you disable OLE drag in TPTShellTree or TPTShellList,
  110.                  you can then activate Delphi drag by setting the DragMode property to dmAutomatic.
  111.                Fixed problem with TPTShellList properties Checkboxes, GridLines, HotTrack and RowSelect
  112.                  not being available at design time in C++Builder 3.
  113.  V1.3c 16Mar98 Added ptsloShowHidden and ptstoShowHidden options.
  114.                Changed default autoscroll delay from 200ms to 100ms.
  115.                Fixed memory leak in TPTShellList.RefreshItems.
  116.                Fixed a number of cases where changing Options in TPTShellList and TPTShellTree
  117.                  controls at run-time would have no effect.
  118.  V1.3b  7Feb98 Fixed: TPTShListData.mDisplayName was not being cleared in the TPTShListData.Flush method, causing
  119.                  various, minor, strange behaviours at times, esp. when editing list item names.
  120.                Fixed: When a tree and list were linked, and the tree control was recreated it would be empty.
  121.                Fixed: When a tree with a non-null BaseFolder was linked to a list, the list would first show the
  122.                  desktop, then the BaseFolder. It no longer initially shows the desktop.
  123.  V1.3a  7Jan98 Added extra validity checking for node and item .Data properties. This makes it possible to
  124.                  add non-shell items to shell controls - see new NonShellNodes example.
  125.                Changed OnEdited event. Now gets fired after the file/folder is renamed, rather than before.
  126.                Fixed: Right-click on non-desktop base node would cause exception.
  127.                Refixed: Fix for CreateNewFolder on empty BaseFolders in TPTShellTree didn't work.
  128.  V1.3  28Nov97 Added support in TPTShellList for remembering the widths of filesystem folder columns
  129.                  between folder changes.
  130.                Fixed non-functional OnExpanding event. Now gets fired.
  131.                Fixed a problem on NT4 where setting a Filter in a TPTShellList would show an unnecessary
  132.                  error box when attempting to view a removable disk when no disk was present.
  133.                Fixed a problem under IE4 and Office97 where .htm, .doc, .xls files etc. could not be
  134.                  opened with a double-click on the shell list control.
  135.                Fixed a problem with TPTShellTree when BaseFolder was set to anything other than desktop, any
  136.                  items dropped onto the root node would be dropped onto the desktop, rather than the root node.
  137.                Fixed. When CreateNewFolder was called for TPTShellTree when the selected folder had no sub-folders,
  138.                  then the "New Folder" node was not displayed or editable.
  139.                Fixed non-functional ptstoDefaultKeyHandling and ptstoOleDrag Options in TPTShellTree. They now work.
  140.                Fixed TPTCustomShellCombo.GoUp and TPTCustomShellTree.GoUp methods. The were ignoring the
  141.                  'levels' parameter.
  142.  V1.2b 12Oct97 OnFillComplete is now published in TPTShellList.
  143.                Fixed a problem where changing the parent of a TPTShellCombo caused access violations. The Windows
  144.                  combobox control was sending multiple WM_DELETEITEM messages per item. A work around has
  145.                  been applied.
  146.                Fixed IE4 problem where floppy was being redundantly accessed.
  147.                Fixed IE4 problem with SendTo menu not working.
  148.                Fixed GDI leak due to a problem with the placement of ShareImages:=TRUE.
  149.  V1.2a  5Oct97 Added OnFillComplete event to TPTShellList and TPTShellTree.
  150.                Fixed problem with accessing node data in OnInsert event.
  151.                Fixed problem where after editing a list item's name, double clicking would use the previous name.
  152.                Fixed slowdown due to event race condition.
  153.                TPTShellList option ptsloDontChangeFolder now works.
  154.                TPTShellList.DoCommandForAllSelected no longer reports an "Unspecified Error" if there are no
  155.                  items selected.
  156.  V1.2   6Sep97 C++Builder support, OLE drag-and-drop, SendTo improvements.
  157.                Added ptsloOleDrag and ptsloOleDrop to the Options property of TPTShellList.
  158.                Added ptstoOleDrag and ptstoOleDrop to the Options property of TPTShellTree.
  159.                Added ptstoExpandWhenSelected to Options property of TPTShellTree.
  160.                Moved icon loading to LVN_GETDISPINFO and TVN_GETDISPINFO notifications. This has the effect of
  161.                  giving the tree and list views a progressive update - especially noticable on slow media such as
  162.                  floppy or CDROM.
  163.                Fixed problem where TPTShellList.OpenSelectedItems caused exceptions with large numbers of items.
  164.                Fixed DoCommand* methods. On some OS flavors not all DoCommand* messages worked. String verbs
  165.                  do not always work as documented. Check the ExecuteContextMenuitem method for the workaround.
  166.                Fixed SendTo - now uses a drag/drop approach that makes non .lnk/.pif files work. It even works
  167.                  with Microsoft PowerToys now.
  168.                Fixed bug with TPTTreeView.SelectedItem not returning correct item.
  169.                Fixed memory leak and added further optimization in TPTListView.FillList .
  170.                Fixed OnInsert event. You can now use the Data item (and the GetDataFromItem method)
  171.                  with the passed TListItem.
  172.                Optimized column click sorting. The list is no longer refilled on every column click.
  173.                Replaced dummy-node mechanism with node.HasChildren.
  174.  V1.1  26Jun97 Delphi 3 support, various fixes and speed improvements.
  175.  V1.0  21Apr97 Released version 1.
  176. }
  177. {$INCLUDE PTCompVer.inc}
  178.  
  179. {$RANGECHECKS OFF} {$OVERFLOWCHECKS OFF} {$WRITEABLECONST OFF}
  180. {$BOOLEVAL OFF}    {$EXTENDEDSYNTAX ON}  {$TYPEDADDRESS ON}
  181.  
  182. interface
  183. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ShellApi,
  184.      StdCtrls, CommCtrl, ComCtrls, ExtCtrls, Menus, Ole2,
  185. {$IFDEF VCL40PLUS}
  186.      ImgList,
  187. {$ENDIF}
  188.      UPTShell95, UPTTreeList, UPTShellUtils, UPTImageCombo;
  189.  
  190. { $DEFINE PTDEBUG} // <-- Define this symbol to turn on leak checking
  191.  
  192. // User messages
  193. const PTSH_AM_CHANGE_NOTIFY = WM_USER + 101;
  194.       PTSH_AM_DEFERRED_EDIT = WM_USER + 102;
  195.       PTSH_AM_DEFERRED_FILL = WM_USER + 103;
  196.       PTSH_AM_LAST          = WM_USER + 150;
  197.  
  198. {$IFDEF VCL20} // Fix for Delphi 2's broken declaration of IDropTarget
  199. type IDropTarget = class(IUnknown)
  200.      end;
  201.  
  202. function RegisterDragDrop(wnd: Integer; dropTarget: IDropTarget): HResult; stdcall;
  203. {$ENDIF}
  204.  
  205.  
  206. type TPTCustomShellCombo = class;   TPTShellCombo = class;         TPTShComboData = class;
  207.      TPTCustomShellTree = class;    TPTShellTree = class;          TPTShTreeData = class;
  208.      TPTCustomShellList = class;    TPTShellList = class;          TPTShListData = class;
  209.  
  210.      TPTShellTreeOption = ( ptstoAutoFill,
  211.                             ptstoVirtualFolders,
  212.                             ptstoDesignInteractive,
  213.                             ptstoDefaultKeyHandling,
  214.                             ptstoContextMenus,
  215.                             ptstoDynamicRefresh,
  216.                             ptstoIncludeNonFolders,
  217.  
  218.                             ptstoOleDrag,            {Allow automatic Ole drag operations}
  219.                             ptstoOleDrop,            {Allow automatic Ole drop operations}
  220.                             ptstoShowHidden
  221.                           );
  222.      TPTShellTreeOptions = set of TPTShellTreeOption;
  223.  
  224.      TPTShellListOption = ( ptsloAutoFill,
  225.                             ptsloNonFilesystemAncestors,
  226.                             ptsloDesignInteractive,
  227.                             ptsloDefaultKeyHandling, {Backspace GoUp(1), Enter, Ctrl+A etc. - if folder open}
  228.                             ptsloContextMenus,       {Allow context menus for items}
  229.                             ptsloDontChangeFolder,   {Disallow GoUp and into folders}
  230.                             ptsloDontGoBelowBase,    {Don't go below Folder}
  231.                             ptsloDynamicRefresh,     {Automatic refresh when list items change}
  232.                             ptsloHideFoldersWhenLinkedToTree, {What it says}
  233.                             ptsloOleDrag,            {Allow automatic Ole drag operations}
  234.                             ptsloOleDrop,            {Allow automatic Ole drop operations}
  235.                             ptsloFolderContextMenu,  {Use default 'no items selected' context menu - not implemented yet}
  236.                             ptsloShowHidden
  237.                           );
  238.      TPTShellListOptions = set of TPTShellListOption;
  239.  
  240.      TPTShellComboOption = (ptscoAutofill,
  241.                             ptscoNonFilesystemAncestors);
  242.      TPTShellComboOptions = set of TPTShellComboOption;
  243.  
  244.  
  245.      TPTShAddItemEvent = procedure( aSender: TObject;
  246.                                     aParentIShf: IShellFolder;
  247.                                     aParentAbsIdList: PItemIdList;
  248.                                     aItemRelIdList: PItemIdList;
  249.                                     aAttribs: Integer;  // Attributes returned from IShellFolder::GetAttributesOf
  250.                                     var afAllowAdd: Bool ) of object;
  251.  
  252.      TPTShTreeInsertItemEvent = procedure( aSender: TObject;
  253.                                            aNode: TTreeNode ) of object;
  254.  
  255.      TPTShTreeDeleteItemEvent = procedure( aSender: TObject;
  256.                                            aNode: TTreeNode;
  257.                                            aShTreeData: TPTShTreeData ) of object;
  258.  
  259.      TPTShListDeleteItemEvent = procedure( aSender: TObject;
  260.                                            aNode: TListItem;
  261.                                            aShListData: TPTShListData ) of object;
  262.  
  263.      TPTShComboDeleteItemEvent = procedure( aSender: TObject;
  264.                                             aItem: Integer;
  265.                                             aShComboData: TPTShComboData ) of object;
  266.  
  267.      TPTShDblClickOpenEvent = procedure( aSender: TObject;  var afHandled: Boolean ) of object;
  268.  
  269.      TPTShPopupHintEvent = procedure( aSender: TObject;  const hint: String ) of object;
  270.  
  271.      TPTShTvCustomDrawEvent = procedure( aSender: TObject;
  272.                                          aCD: TPTCustomDraw;
  273.                                          aNode: TTreeNode;
  274.                                          aData: TPTShTreeData ) of object;
  275.  
  276.      TPTShLvCustomDrawEvent = procedure( aSender: TObject;
  277.                                          aCD: TPTCustomDraw;
  278.                                          aItem: TListItem;
  279.                                          aData: TPTShListData ) of object;
  280.  
  281.    {The TPTShellLocator class is effectively a Variant type for shell object locations.
  282.  
  283.     Use to reference a shell object. You can reference a shell object in one
  284.     of three ways:
  285.       1) By PIDL
  286.       2) By pathname
  287.       3) By CSIDL (indirect system reference)
  288.  
  289.     This is simplified by always storing PIDL or Pathname as PIDL (converting to/from pathname
  290.     on read/write). Leaving two options:
  291.       1) By PIDL (Pathname)
  292.       2) By CSIDL
  293.  
  294.     You would want to use a CSIDL to locate such folders as the Start Menu, or Program Files folder.
  295.     Navigating to your particular folder at design time and storing as a PIDL is not sufficient. Remember
  296.     that a PIDL is just a binary pathname. For example, if you selected C:\WINDOWS\START MENU\ as a PIDL
  297.     on another machine the Start Menu might be at E:\WIN95\START MENU\ and your code will break.
  298.  
  299.     You should therefore use absolute PIDLs carefully. Items you are safe in referencing are anything that will
  300.     appear on all computers (Desktop, My Computer, Network Neighbourhood, Recycle Bin). However, you could
  301.     just as easily use a CSIDL to reference many of these objects as well.
  302.  
  303.     This class provides three properties for access in the three different ways. The mode is
  304.     selected on write, but conversion is done on read (except for indirect system reference).
  305.  
  306.       mLocator.PIDL := pIdList;   // Selects PIDL/Pathname mode
  307.       mLocator.Pathname := 'C:\'; // Selects PIDL/Pathname mode
  308.       mLocator.CSIDL := csidlStartMenu;  // Selects sysref mode
  309.  
  310.     }
  311.      TPTShellLocator_Which = (usePidl, useCSIDL); // C++Builder demands a formal type for enumerations.
  312.      TPTShellLocator = class(TPersistent)
  313.        public
  314.          destructor Destroy; override;
  315.  
  316.          procedure Assign( source: TPersistent ); override;
  317.          function  IsEqual( aValue: TPTShellLocator ): Boolean;
  318.  
  319.          procedure Clear;
  320.  
  321.          property IdList: PItemIdList read GetIdList write SetIdList;
  322.          property PathName: String read GetPathName write SetPathName;
  323.  
  324.          property CSIDL: TCSIDL read GetCSIDL write SetCSIDL;
  325.  
  326.          property OnChange: TNotifyEvent read mOnChange write mOnChange;
  327.      end; {TPTShellLocator}
  328.  
  329.  
  330.      TPTCustomShellTree = class(TPTCustomTreeView)
  331.        public
  332.          constructor Create( aOwner: TComponent ); override;
  333.          destructor  Destroy; override;
  334.  
  335.          procedure FillItems;
  336.          procedure RefreshNodes;
  337.          function  GetDataFromNode(node: TTreeNode): TPTShTreeData;
  338.          procedure GoUp( aLevels: Integer );
  339.  
  340.          function  CreateNewFolder( afEditNow: Boolean ): Boolean;
  341.  
  342.          function  DoCommandForNode( aNode: TTreeNode;  aCmd: PChar ): HResult;
  343.  
  344.          function  FindNodeWithIdList( baseNode: TTreeNode;  pidl: PItemIdList ): TTreeNode;
  345.  
  346.          procedure ProcessMenu( aItem: TTreeNode;  at: TPoint ); dynamic;
  347.  
  348.          procedure SortNode( aTreeNode: TTreeNode );
  349.  
  350.          procedure Synchronize( afApplyToGroup: Boolean );
  351.  
  352.          function  GetDragDropAttributesForNode(node: TTreeNode): DWORD;
  353.      end; {TPTCustomShellTree}
  354.  
  355.  
  356.      TPTShellTree = class(TPTCustomShellTree)
  357.        public
  358.          property SelectedItem;
  359.          property SelectedFolder;
  360.          property SelectedPathName;
  361.          property ShTreeData;
  362.          property Items; // From TCustomTreeView
  363.        published
  364.          property BaseFolder;
  365.  
  366.          property OnNodeContextMenu;
  367.  
  368.          property ShellList;
  369.          property Options;
  370.  
  371.          property OnAddItem;
  372.          property OnDeleteItem;
  373.          property OnInsertItem;
  374.          property OnPopupHint;
  375.  
  376.          property OnCustomDrawSh;
  377.          property OnCustomDrawShEx;
  378.          property OnFillComplete;
  379.          property OnFillStart;
  380.  
  381.         // From TCustomTreeView
  382.          property ShowButtons;
  383.          property BorderStyle;
  384.          property DragCursor;
  385.          property ShowLines;
  386.          property ShowRoot default True;
  387.          property ReadOnly default false;
  388.          property DragMode;
  389.          property HideSelection;
  390.          property Indent;
  391.          property OnEditing;
  392.          property OnEdited;
  393.          property OnExpanding;
  394.          property OnExpanded;
  395.          property OnCollapsing;
  396.          property OnCollapsed;
  397.          property OnChanging;
  398.          property OnChange;
  399.          property OnDeletion;
  400.          property OnGetImageIndex;
  401.          property OnGetSelectedIndex;
  402.          property Align;
  403.          property Enabled;
  404.          property Font;
  405.          property Color;
  406.          property ParentColor default false;
  407.          property ParentCtl3D;
  408.          property ParentFont;
  409.          property Ctl3D;
  410.          property TabOrder;
  411.          property TabStop default True;
  412.          property Visible;
  413.          property OnClick;
  414.          property OnEnter;
  415.          property OnExit;
  416.          property OnDragDrop;
  417.          property OnDragOver;
  418.          property OnStartDrag;
  419.          property OnEndDrag;
  420.          property OnMouseDown;
  421.          property OnMouseMove;
  422.          property OnMouseUp;
  423.          property OnDblClick;
  424.          property OnKeyDown;
  425.          property OnKeyPress;
  426.          property OnKeyUp;
  427.          property PopupMenu;
  428.          property ParentShowHint;
  429.          property ShowHint;
  430.          property StateImages;
  431.  
  432. {$IFDEF VCL30PLUS}
  433.          property RightClickSelect;
  434. {$ENDIF}
  435.  
  436. {$IFDEF VCL40PLUS}
  437.          property Anchors;
  438.          property AutoExpand;
  439.          property BiDiMode;
  440.          property BorderWidth;
  441.          property ChangeDelay;
  442.          property Constraints;
  443.          property DragKind;
  444.          property HotTrack;
  445.          property ParentBiDiMode;
  446.          property RowSelect;
  447.          property ToolTips;
  448.          property OnEndDock;
  449.          property OnStartDock;
  450.          property OnMouseWheelDown;
  451.          property OnMouseWheelUp;
  452.          property OnMouseWheel;
  453.          property OnCustomDraw;
  454.          property OnCustomDrawItem;
  455. {$ENDIF}
  456.  
  457. {$IFDEF VCL50PLUS}
  458.          property OnAdvancedCustomDraw;
  459.          property OnAdvancedCustomDrawItem;
  460.          property OnContextPopup;
  461. {$ENDIF}
  462. //         property OnCompare;
  463. //         property SortType;
  464. //         property Images;
  465.      end; {TPTShellTree}
  466.  
  467.  
  468.      TPTCustomShellList_LCS = (lcsNone, lcsShellDetails, lcsDefault); // C++Builder demands formal type for enumerations.
  469.      TPTCustomShellList = class(TPTCustomListView)
  470.        public
  471.          constructor Create( aOwner: TComponent ); override;
  472.          destructor  Destroy; override;
  473.  
  474.          function  CreateNewFolder( afEditNow: Boolean ): Boolean;
  475.          procedure DoCommandForItem( aItem: TListItem;  cmd: PChar );
  476.          procedure DoCommandForAllSelected( cmd: PChar );  // See help for a list of available commands
  477.          procedure DoCommandForFolder( cmd: PChar );
  478.          procedure FillItems;
  479.          procedure GoUp( aLevels: Integer );
  480.          function  GetDataFromItem(item: TListItem): TPTShListData;
  481.          procedure OpenItem( aItem: TListItem );
  482.          procedure OpenSelectedItems;
  483.          procedure ProcessMenu( aItem: TListItem;  at: TPoint );
  484.          procedure ProcessMenuForAllSelected( at: TPoint );
  485.          procedure ProcessSendTo( idx: Integer );
  486.  
  487.          procedure RefreshItems;
  488.  
  489.          function  GetDragDropAttributesForAllSelected: DWORD;
  490.          function  GetDragDropAttributesForItem(item: TListItem): DWORD;
  491.  
  492.          procedure SelectAll; {$IFDEF VCL60PLUS} override; {$ENDIF}
  493.          function  ShellSelCount: Integer;// Returns the number of shell items selected. Non-shell items are not counted.
  494.          procedure SortList;
  495.          procedure Synchronize( afApplyToGroup: Boolean );
  496.      end; {TPTCustomShellList}
  497.  
  498.  
  499.      TPTShellList = class(TPTCustomShellList)
  500.        public
  501.          property SelectedItem;
  502.          property ShListData;
  503.          property SortColumn;
  504.  
  505.         //-- From TPTCustomShellList
  506.          property Columns; // Don't change the columns
  507.          property Items;
  508.          property _IShellFolder;
  509.  
  510.          // These
  511.          property HeaderCanvas;
  512.          property HeaderHandle;
  513.          property HeaderSortColumn;
  514.          property HeaderSortDirection;
  515.  
  516.        published
  517.         //-- From TPTCustomListView
  518.          property HeaderSortDisplayMode;
  519.          property OnItemContextMenu;
  520.  
  521.         //-- From TPTCustomShellList
  522.          property Options;
  523.          property Folder;
  524.          property FileFilter;
  525.  
  526.          property OnAddItem;
  527.          property OnDeleteItem;
  528.          property OnPopupHint;
  529.          property OnDblClickOpen;
  530.  
  531.          property OnCustomDrawSh;
  532.          property OnCustomDrawShEx;
  533.          property OnFillComplete;
  534.          property OnFillStart;
  535.          property OnFolderChanged;
  536.  
  537.         //--
  538.          property Align;
  539.          property BorderStyle;
  540.          property Color;
  541.          property ColumnClick;
  542.          property OnClick;
  543.          property OnDblClick;
  544.          property Ctl3D;
  545.          property DragMode;
  546.          property Enabled;
  547.          property ReadOnly default false;
  548.          property Font;
  549.          property ParentColor default false;
  550.          property ParentCtl3D;
  551.          property ParentFont;
  552.          property HideSelection;
  553.          property IconOptions;
  554.          property MultiSelect;
  555.          property OnChange;
  556.          property OnChanging;
  557.          property OnColumnClick;
  558.          property OnDeletion;
  559.          property OnEdited;
  560.          property OnEditing;
  561.          property OnEnter;
  562.          property OnExit;
  563.          property OnInsert;
  564.          property OnDragDrop;
  565.          property OnDragOver;
  566.          property DragCursor;
  567.          property OnStartDrag;
  568.          property OnEndDrag;
  569.          property OnMouseDown;
  570.          property OnMouseMove;
  571.          property OnMouseUp;
  572.          property ParentShowHint;
  573.          property ShowHint;
  574.          property PopupMenu;
  575.          property ShowColumnHeaders;
  576.          property TabOrder;
  577.          property TabStop default True;
  578.          property ViewStyle;
  579.          property Visible;
  580.          property OnKeyDown;
  581.          property OnKeyPress;
  582.          property OnKeyUp;
  583.          property StateImages;
  584.          property OnCompare;
  585. //         property SortType;
  586. //         property AllocBy;
  587. //         property LargeImages;
  588. //         property SmallImages;
  589. {$IFDEF VCL30PLUS}
  590.          property Checkboxes;
  591.          property GridLines;
  592.          property HotTrack;
  593.          property RowSelect;
  594. {$ENDIF}
  595.  
  596. {$IFDEF VCL40PLUS}
  597.          property Anchors;
  598.          property BiDiMode;
  599.          property BorderWidth;
  600.          property Constraints;
  601.          property DragKind;
  602.          property FlatScrollBars;
  603.          property FullDrag;
  604.          property HotTrackStyles default [];
  605.          property OwnerData;
  606.          property OwnerDraw;
  607.          property ParentBiDiMode;
  608.          property OnData;
  609.          property OnDataFind;
  610.          property OnDataHint;
  611.          property OnDataStateChange;
  612.          property OnDrawItem;
  613.          property OnGetImageIndex;
  614.          property OnResize;
  615.          property OnEndDock;
  616.          property OnSelectItem;
  617.          property OnStartDock;
  618.          property OnMouseWheelDown;
  619.          property OnMouseWheelUp;
  620.          property OnMouseWheel;
  621.          property OnCustomDraw;
  622.          property OnCustomDrawItem;
  623. {$ENDIF}
  624.  
  625. {$IFDEF VCL50PLUS}
  626.          property OnAdvancedCustomDraw;
  627.          property OnAdvancedCustomDrawItem;
  628.          property OnContextPopup;
  629.          property OnInfoTip;
  630. {$ENDIF}
  631.      end; {TPTShellList}
  632.  
  633.  
  634.      TPTCustomShellCombo = class(TPTCustomImageCombo)
  635.        public
  636.          constructor Create( aOwner: TComponent ); override;
  637.          destructor  Destroy;  override;
  638.  
  639.          procedure FillItems;
  640.  
  641.          procedure GoUp( aLevels: Integer );
  642.  
  643.          procedure Synchronize( afApplyToGroup: Boolean );
  644.      end; {TPTCustomShellCombo}
  645.  
  646.  
  647.      TPTShellCombo = class(TPTCustomShellCombo)
  648.        public
  649.          property SelectedFolder;
  650.          property ShComboData;
  651.  
  652.        published
  653.          property ShellTree;
  654.          property ShellList;
  655.          property IndentPixels;
  656.          property Options;
  657.  
  658.         //--
  659.          property Color;
  660.          property Ctl3D;
  661.          property DragMode;
  662.          property DragCursor;
  663.          property DropDownCount;
  664.          property Enabled;
  665.          property Font;
  666.          property ParentColor;
  667.          property ParentCtl3D;
  668.          property ParentFont;
  669.          property ParentShowHint;
  670.          property PopupMenu;
  671.          property ShowHint;
  672.          property Sorted;
  673.          property TabOrder;
  674.          property TabStop;
  675.          property Visible;
  676.          property OnChange;
  677.          property OnClick;
  678.          property OnDblClick;
  679.          property OnDragDrop;
  680.          property OnDragOver;
  681.          property OnDrawItem;
  682.          property OnDropDown;
  683.          property OnEndDrag;
  684.          property OnEnter;
  685.          property OnExit;
  686.          property OnKeyDown;
  687.          property OnKeyPress;
  688.          property OnKeyUp;
  689.          property OnMeasureItem;
  690.          property OnStartDrag;
  691.  
  692. {$IFDEF VCL40PLUS}
  693.          property Anchors;
  694.          property Constraints;
  695.          property DragKind;
  696.          property ImeMode;
  697.          property ImeName;
  698.          property BiDiMode;
  699.          property ParentBiDiMode;
  700.          property OnEndDock;
  701.          property OnStartDock;
  702. {$ENDIF}
  703.  
  704. {$IFDEF VCL50PLUS}
  705.          property OnContextPopup;
  706. {$ENDIF}
  707.  
  708.         // -- Added by TPTCustomCombobox
  709.          property OnDeleteItem;
  710.          property OnCloseUp;
  711.          property OnSelEndCancel;
  712.          property OnSelEndOk;
  713.  
  714.         // -- Deliberately hidden properties
  715.         // property MaxLength;
  716.         // property Text;
  717.      end;
  718.  
  719.  
  720. // -- Data classes ----------------------------------------
  721.      TPTShTreeData = class(TObject)
  722.        public
  723.          constructor Create( aOwner: TPTCustomShellTree );
  724.          destructor  Destroy; override;
  725.  
  726.          function GetIDropTarget( h: HWND;  var idt: IDropTarget ): HResult;
  727.  
  728.          function IsRootDir: Boolean;
  729.          procedure Flush; // Remove any cached data (mAbsPidl and mThisIshf);
  730.  
  731.          property Parent: TPTShTreeData read mParent;
  732.          property ParentIShf: IShellFolder read GetParentIShf;
  733.          property AbsoluteIdList: PItemIdList read GetAbsPidl;
  734.          property RelativeIdList: PItemIdList read mRelPidl;
  735.          property ThisIShf: IShellFolder read GetThisIshf;
  736.          property PathName: String read GetPathName;
  737.          property Editable: Boolean read GetEditable;
  738.          property Data: Pointer read mData write mData;  // User defined data
  739.      end; {TPTShTreeData}
  740.  
  741.  
  742.      TPTShListData = class(TObject)
  743.        public
  744.          constructor Create( aOwner: TPTCustomShellList );
  745.          destructor  Destroy; override;
  746.  
  747.          function IsFolder: Boolean;
  748.          function IsLnkShortcut: Boolean;
  749.          function IsValid: Boolean;
  750.          function IsFileSystem: Boolean;
  751.  
  752.          procedure Flush;
  753.  
  754.          property Owner: TPTCustomShellList read mOwner;
  755.          property AbsoluteIdList: PItemIdList read GetAbsoluteIdList;
  756.          property Editable: Boolean read GetEditable;
  757.          property RelativeIdList: PItemIdList read mRelPidl;
  758.          property Attributes: DWORD read GetAttributes;
  759.          property DisplayName: String read GetDisplayName;
  760.          property FileName: String read GetFilename;
  761.          property PathName: String read GetPathName;
  762.  
  763.          property ColText[ col: Integer ]: String read GetColText;
  764.  
  765.          property Size: String read GetSize;
  766.          property FileType: String read GetFileType;
  767.          property Modified: String read GetModified;
  768.  
  769.          property Data: Pointer read mData write mData;  // User defined data
  770.      end; {TPTShListData}
  771.  
  772.  
  773.      TPTShComboData = class(TObject)
  774.        public
  775.          constructor Create( aOwner: TPTCustomShellCombo );
  776.          destructor  Destroy; override;
  777.  
  778.          property ParentIdList: PItemIdList read mParentPidl;
  779.          property ParentIShf: IShellFolder read mishfParent;
  780.          property RelativeIdList: PItemIdList read mRelPidl;
  781.          property AbsoluteIdList: PItemIdList read mAbsPidl;
  782.          property ThisIShf: IShellFolder read GetThisIshf;
  783.          property Data: Pointer read mData write mData; // User defined data
  784.      end; {TPTShComboData}
  785.  
  786.  
  787. function PTShCreateNewFolder( aPathname: String;  var aNewName: String ): Boolean;
  788.  
  789. var PTSH_CHANGE_NOTIFY_DELAY: Integer = 2000;    // Milliseconds delay between when a change is detected and when the view is updated.
  790.     PTSH_CHANGE_NOTIFY_FASTDELAY: Integer = 400; // Milliseconds delay between when a change is detected and when the view is updated when the control is focused.
  791.     PTSH_TREE_KEY_UPDATE_DELAY: Integer = 500;   // Milliseconds delay between a keyboard based move of the tree selection
  792.                                                  // and when any associated tree or combo is updated.
  793.     PTSH_MAX_FOLDER_ATTEMPTS: Integer = 50;      // Maximum number of times to try creating a new folder
  794.  
  795.     PTSH_AUTOSCROLL_THRESHOLD_X: Integer = (20 * 13) div 10;
  796.     PTSH_AUTOSCROLL_THRESHOLD_Y: Integer = 20;
  797.     PTSH_AUTOSCROLL_MINDELAY_MS: Integer = 100;  // Milliseconds minimum delay between autoscrolls during OLE drag/drop
  798.  
  799. var CF_IDLIST: TClipFormat;  // Registered clipboard format for IDList structures
  800.  
  801. {*****************************************************************************}
  802. implementation
  803.